package com.istock.union;

import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;

import com.istock.base.web.filter.XssSqlFilter;

@SpringBootApplication
public class UnionApplication {

	public static void main(String[] args) {
		SpringApplication.run(UnionApplication.class, args);
		System.out.println("==============application start finish==============");
	}
	
	@Bean
	public FilterRegistrationBean xssFilterRegistration()
	{
		FilterRegistrationBean registrationBean = new FilterRegistrationBean();
		XssSqlFilter filter = new XssSqlFilter();
//		filter.setExcludeRegx("排除url正则");//requestURI
		registrationBean.setFilter(filter);
		List<String> urlPatterns = new ArrayList<String>();
	    urlPatterns.add("/*");
	    registrationBean.setUrlPatterns(urlPatterns);
	    registrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);
//	    registrationBean.setOrder(1);
		return registrationBean;
	}
}
